package com.learn.mvp.presenter;

import com.learn.mvp.model.ILoginModel;
import com.learn.mvp.model.LoginModel;
import com.learn.mvp.view.ILoginView;

public class LoginPresenter implements ILoginPresenter{

    private ILoginModel loginModel;

    private ILoginView loginView;

    public LoginPresenter(ILoginView loginView) {
        this.loginView = loginView;
        this.loginModel = new LoginModel(this);
    }

    @Override
    public void loginToServer(String userName, String password) {
        loginView.showProgress(true);
        loginModel.login(userName,password);
    }

    @Override
    public void loginSucceed() {
        loginView.showProgress(false);
        loginView.showLoginSucceedView();
    }

    @Override
    public void loginFailed() {
        loginView.showProgress(false);
        loginView.showLoginFailedView();
    }
}
